<?php $dem = 0; ?>
<?php foreach($items As $item): ?>
<tr class="<?php print ( $dem%2 == 0) ? '': 'alt'; ?>">
    <td><a href="<?php print site_url('roles/edit/'.$item->role_id); ?>"><?php print $item->role_name; ?></a></td>
    <td><?php print $item->description; ?></td>
    <td><?php print $item->default; ?></td>
    <td></td>
    <td><input type="checkbox" name="checkall" value="<?php print $item->role_id; ?>"></td>
</tr>
<?php $dem++; ?>
<?php endforeach; ?>
<tr>
    <td colspan="5">
        <ul class="pagination">
            <?php if($page > 1): ?>
            <?php $prev = $page -1; ?>
            <li class="text"><a href="<?php print site_url('roles/list_role/'.$prev); ?>">Previous</a></li>
            <?php endif; ?>
            
            <?php for($i = $page-$space; $i <= $page+$space;$i++): ?>
                <?php if($i > 0 && $i <= $totalPages): ?>
                    <?php if($i == $page): ?>
                        <li class="page"><a class="current" href="javascript:void(0);" title=""><?php print $i; ?></a></li>
                    <?php else: ?>
                        <li><a href="<?php print site_url('roles/list_role/'.$i); ?>" title=""><?php print $i; ?></a></li>
                    <?php endif; ?>
                <?php endif; ?>
            <?php endfor; ?>

            <?php if($page < $totalPages): ?>
            <?php $next = $page +1; ?>
            <li class="text"><a href="<?php print site_url('roles/list_role/'.$next); ?>" title="">Next</a></li>
            <?php endif; ?>
        </ul>
    </td>
</tr>
